const proxy = require('http-proxy-middleware');

module.exports = function(app) {
  // ...You can now register proxies as you wish!

  app.use(
    "/api/v2",
    proxy({
      target: `https://www.airbnb.cn/api/v2`,
      changeOrigin: true,
      pathRewrite: {
        '^/api/v2': ''
      }
    }),
  );
  app.use(
    "/api",
    proxy({
      target: `http://localhost:${process.env.PORT}/mock`,
      changeOrigin: true,
      pathRewrite: {
        '^/api': ''
      }
    }),
  )
  // app.use(proxy('/api', {
  //   target: 'https://staging.kangyu.co',
  //   secure: false,
  //   changeOrigin: true,
  //   pathRewrite: {
  //     '^/api': '/'
  //   },
  // }));
  // app.use(proxy('/apc', { target: 'http://172.19.5.34:9531' }));
};

// const proxy = require('http-proxy-middleware');
//
// module.exports = function(app) {
//   app.use(proxy('/api', {
//   target: 'http://192.168.1.144:8181',
//     secure: false,
//       changeOrigin: true,
//     pathRewrite: {
//     "^/api": "/"
//   },
//   // cookieDomainRewrite: "http://localhost:3000"
// }));
// };
